import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:sph_driver/AppConfig/Config.dart';

import 'search_textfield.dart';

class RouteSearchBar extends StatefulWidget {
  final TextEditingController? startCityController;
  final TextEditingController? endCityController;
  final TextEditingController? startController;
  final TextEditingController? endController;
  final VoidCallback? callback;

  const RouteSearchBar({
    Key? key,
    this.startCityController,
    this.endCityController,
    this.startController,
    this.endController,
    this.callback,
  }) : super(key: key);

  @override
  _RouteSearchBarState createState() => _RouteSearchBarState();
}

class _RouteSearchBarState extends State<RouteSearchBar> {
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    if (widget.callback != null) {
      widget.callback!();
    }
  }
  @override
  Widget build(BuildContext context) {
    var screenSize = MediaQuery.of(context).size;

    return Container(
      color: MyColors.themeColor,
      height: 80,
      padding: EdgeInsets.all(5),
      child: Container(
        child: Row(
          children: [
            Container(
              child: Column(
                children: [
                  Container(
                    child: Row(
                      children: [
                        // SearchTextField(
                        //   controller: widget.startCityController,
                        //   title: "城市：",
                        //   width: 70.w,
                        // ),
                        SearchTextField(
                          controller: widget.startController,
                          title: "起点：",
                          width: (screenSize.width -100.w),
                        ),
                      ],
                    ),
                  ),
                  Container(
                    child: Row(
                      children: [
                        // SearchTextField(
                        //   controller: widget.endCityController,
                        //   title: "城市：",
                        //   width: 90,
                        // ),
                        SearchTextField(
                          controller: widget.endController,
                          title: "终点：",
                          width: (screenSize.width -100.w),
                        ),
                      ],
                    ),
                  ),
                ],
              ),
            ),
            // Container(
            //   padding: EdgeInsets.only(left: 2),
            //   child: BMFSearchBtn(
            //     title: "查询",
            //     borderRadius: 15,
            //     color: Colors.white,
            //     titleTextStyle: TextStyle(color: MyColors.themeColor),
            //     onTap: () {
            //       if (widget.callback != null) {
            //         widget.callback!();
            //       }
            //     },
            //   ),
            // )
          ],
        ),
      ),
    );
  }
}
